<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
class CI_DB_pdo_informix_forge extends CI_DB_pdo_forge
{
	/**
	 * RENAME TABLE statement
	 *
	 * @var	string
	 */
	protected $_rename_table = 'RENAME TABLE %s TO %s';
	/**
	 * UNSIGNED support
	 *
	 * @var	array
	 */
	protected $_unsigned = array('SMALLINT' => 'INTEGER', 'INT' => 'BIGINT', 'INTEGER' => 'BIGINT', 'REAL' => 'DOUBLE PRECISION', 'SMALLFLOAT' => 'DOUBLE PRECISION');
	/**
	 * DEFAULT value representation in CREATE/ALTER TABLE statements
	 *
	 * @var	string
	 */
	protected $_default = ', ';

	protected function _alter_table($alter_type, $table, $field)
	{
		if ($alter_type === 'CHANGE') {
			$alter_type = 'MODIFY';
		}

		return parent::_alter_table($alter_type, $table, $field);
	}

	protected function _attr_type(&$attributes)
	{
		switch (strtoupper($attributes['TYPE'])) {
		case 'TINYINT':
			$attributes['TYPE'] = 'SMALLINT';
			$attributes['UNSIGNED'] = false;
			return NULL;
		case 'MEDIUMINT':
			$attributes['TYPE'] = 'INTEGER';
			$attributes['UNSIGNED'] = false;
			return NULL;
		case 'BYTE':
		case 'TEXT':
		case 'BLOB':
		case 'CLOB':
			$attributes['UNIQUE'] = false;

			if (isset($attributes['DEFAULT'])) {
				unset($attributes['DEFAULT']);
			}

			return NULL;
		default:
			return NULL;
		}
	}

	protected function _attr_unique(&$attributes, &$field)
	{
		if (!empty($attributes['UNIQUE']) && ($attributes['UNIQUE'] === true)) {
			$field['unique'] = ' UNIQUE CONSTRAINT ' . $this->db->escape_identifiers($field['name']);
		}
	}

	protected function _attr_auto_increment(&$attributes, &$field)
	{
	}
}

?>
